package com.dajiba.demo;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.LogUtils;

public class CustomDrawCake extends BaseCustomView {

    public CustomDrawCake(Context context) {
        super(context);
    }

    public CustomDrawCake(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomDrawCake(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        drawArc(canvas, Color.BLACK, 0, 10, 360, 360);
        drawArc(canvas, Color.BLUE, 10, 5, 360, 370);
        drawArc(canvas, Color.GREEN, 15, 80, 360, 380);
        drawArc(canvas, Color.RED, 95, 30, 340, 360);
        drawArc(canvas, Color.GRAY, 125, 150, 340, 340);
        drawArc(canvas, Color.YELLOW, 275, 85, 360, 340);
    }

    private void drawArc(Canvas canvas, int color, float startAngle, float sweepAngle, int x, int y) {
        Paint paint2 = new Paint();
        paint2.setColor(color);
        paint2.setAntiAlias(true);
        canvas.drawArc(new RectF(x, y, 400 + x, 400 + y), startAngle, sweepAngle, true, paint2);
    }


}
